#ifndef ORDERMANAGE_H
#define ORDERMANAGE_H

#include <QDialog>
#include <QStandardItemModel>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlRecord>

namespace Ui {
class OrderManage;
}

class OrderManage : public QDialog
{
    Q_OBJECT

public:
    explicit OrderManage(QSqlDatabase db, QWidget *parent = nullptr);
    ~OrderManage();

private slots:
    void onSearchTextChanged(const QString &text);
    void onStatusFilterChanged(int index);
    void onDateFilterChanged(int index);

    void showOrderDetails();

    void on_pushButton_clicked();
    void on_exportButton_clicked();

private:
    Ui::OrderManage *ui;
    QStandardItemModel *model;
    QSqlDatabase m_db;

    void applyFilters();  // 应用所有筛选条件
    void initFilters();   // 初始化筛选器
    void addSampleData();
    void setupConnections();
    void loadDataFromDatabase(); // 从数据库加载数据到表格
    QString currentSearchText;
    QString currentStatusFilter;
    QString currentDateFilter;
};

#endif // ORDERMANAGE_H
